#ifndef AABB_HPP
#define AABB_HPP

#include "vec_operation.hpp"

/**
 * @brief This a basic three dimension AABB representation
 *
 */
class AABB3 {
public:
  AABB3() : pmin(), pmax() {}

  AABB3( vec3f min, vec3f max ) : pmin(min), pmax(max) {}

  // Get center of the bounding box
  vec3f c() { return ( pmin + pmax ) / 2.f; }

  /**
   * @brief Get size(width, height, length) of the bounding box 
   */
  vec3f s() { return pmax - pmin; }

  // Get radius vector of the bounding box
  vec3f r() { return s() / 2.f; }

  // reset current bounding box
  void reset() { LOOP_VEC( pmin[i] = FLT_MAX; pmax[i] = -FLT_MAX;, 3 ) }

  // add point to this bounding box
  void add( const vec3f &p ) {
    pmin = minVec(pmin, p);
    pmax = maxVec(pmax, p);
  }

private:
  vec3f pmin;
  vec3f pmax;
};

#endif